Skip to content

Remove unused code: phase1-structural - #4

Draft
tomtourwe wants to merge 87 commits into
mainfrom
codelaser/fix-dead-code-20261120-125740
Draft

tomtourwe wants to merge 87 commits into
mainfrom
codelaser/fix-dead-code-20261120-125740

Conversation

@tomtourwe

@tomtourwe tomtourwe commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

private and package-private main code, structural clusters, small-modules: 21 clusters, 258 lines

Removes 23 unused code roots and the code only they used.

Roots:

  • org.hibernate.action.queue.internal.FlushCoordinator.CompositeOperationGroupKey
  • org.hibernate.boot.jaxb.hbm.transform.TargetColumnAdapter.setInsertable(java.lang.Boolean)
  • org.hibernate.boot.jaxb.hbm.transform.TargetColumnAdapter.setUpdatable(java.lang.Boolean)
  • org.hibernate.cache.internal.EnabledCaching.qualifiedRegionName(org.hibernate.cache.spi.DomainDataRegion)
  • org.hibernate.collection.spi.PersistentBag.SimpleRemove
  • org.hibernate.collection.spi.PersistentList.Add
  • org.hibernate.community.dialect.DB2LegacyDialect:FOR_SHARE_SKIP_LOCKED_SQL
  • org.hibernate.community.dialect.DB2LegacyDialect:FOR_UPDATE_SKIP_LOCKED_SQL
  • org.hibernate.community.dialect.GaussDBDialect.NativeParameterMarkers
  • org.hibernate.community.dialect.MySQLLegacyDialect.supportsAliasLocks()
  • org.hibernate.community.dialect.MySQLLegacyDialect.supportsForShare()
  • org.hibernate.dialect.DB2Dialect:FOR_SHARE_SKIP_LOCKED_SQL
  • org.hibernate.dialect.DB2Dialect:FOR_UPDATE_SKIP_LOCKED_SQL
  • org.hibernate.dialect.DB2iDialect:FOR_UPDATE_SKIP_LOCKED_SQL
  • org.hibernate.dialect.aggregate.internal.SybaseASEAggregateSupport.XmlWriteExpression.isAggregate()
  • org.hibernate.orm.post.ClassificationGraph.Edge.getSourceElementId()
  • org.hibernate.orm.post.ClassificationReportRenderer.ProjectionEntry.getElementId()
  • org.hibernate.processor.validation.MockCollectionPersister.getElementPropertyType(java.lang.String)
  • org.hibernate.processor.validation.MockEntityPersister.isSamePersister(org.hibernate.processor.validation.MockEntityPersister)
  • org.hibernate.processor.validation.MockSessionFactory.isConstructorDefined(java.lang.String,java.util.List)
  • org.hibernate.spatial.predicate.JTSFilterPredicate
  • org.hibernate.sql.results.internal.StandardRowReader.ComponentType.getComponentType()
  • org.hibernate.tool.hbm2ddl.Exporter

The project's tests were not run on this branch.

The clusters of this pull request in the dead code viewer

Questions about this pull request: @tomtourwe

Srltas and others added 30 commits November 16, 2026 18:54
A fetch join whose join type is right or full has no sensible meaning:
the null-extended rows have no owner to attach the fetched association
to, so they showed up as null elements of the result list, or the join
type was silently degraded when @softdelete was involved.

The AbstractSqmAttributeJoin constructor now throws
IllegalArgumentException for a fetched join of type RIGHT or FULL,
which covers From.fetch(..., JoinType) and treatAs(..., fetch) in the
criteria API. HQL 'right join fetch' and 'full join fetch' are rejected
earlier, in SemanticQueryBuilder.consumeJoin(), with a SemanticException
carrying the query string.

Inner and left fetch joins, and right or full joins which are not
fetched, are unaffected.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A join whose target is an entity name or a CTE, rather than an
association, cannot be fetched. Until now 'join fetch Entity e on ...'
was accepted with the 'fetch' silently ignored (logged at DEBUG), and
'join fetch cte' was accepted with no indication at all, whereas
'fetch' on a subquery or set-returning function join was already an
error.

QualifiedJoinPathConsumer now throws a SemanticException in both
cases, and the unused 'Ignoring fetch on entity join' log message is
removed.

Entity and CTE joins without 'fetch' are unaffected.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Rollback never invokes the before-completion writer, so the queue kept its
pending work and its registered flag, and the next transaction did not
register a fresh writer.
Oracle requires the SQL object type name even when there is no value.
SQL sizes describe the relational value, which may differ from a
converter's domain type.
An explicit fractional-second precision now generates time(n). Omitting it
still generates plain time, keeping the server's seven-digit default, and
stays distinct from an explicit zero, including in casts.
XMLELEMENT turns a missing child into an empty element, so a null nested
aggregate was read back as non-null in projections and null predicates.
Guard the child query, and compose nested paths against the original
document so each level does not duplicate the parent SQL.
Historical predicates and audit writes now take the changeset identifier
mapping from the audit column, instead of resolving an application-wide
default again from the Java type.
…action

With edb_redwood_date enabled, EDB evaluates current_timestamp (and
localtimestamp) per statement, not per transaction. PostgresPlusDialect
inherited isCurrentTimestampStable() == true from PostgreSQLDialect, so
with server transaction timestamps each history statement rendered its own
current_timestamp. One transaction then wrote several different timestamps
and left gaps between a superseded history row and its successor.

Report the timestamp as not stable, so it is fetched once per transaction
and bound as a parameter.

Reproduced on EDB Advanced Server 17.4: the new test fails without this
change and passes with it.
…upport

A BETWEEN over a tuple was rendered with row-value syntax even when the
dialect reports no support for row ordering comparisons. Use the existing
lexicographic comparison emulation instead.
…ion calls

Registering a callable parameter or function return with an embeddable Type
now uses the embeddable's single-column aggregate mapping, as registration
by Java class already does. An embeddable without one is rejected at
registration; multi-column callable values are not supported.
…ion test expectations

Use a WHERE clause for Spanner cleanup and accept JDBCException for
jConnect batch failures while retaining rollback assertions.

Clamp SQL Server TIME rounding expectations at the end of the day.

SpannerPostgreSQLDialect should advertise non-stable timestamps.

Signed-off-by: Steve Ebersole <steve@hibernate.org>
not() on a negated comparison predicate returned another negated
predicate instead of the affirmative one.

The operator which a comparison predicate stands for, taking negation
into account, is now given by getEffectiveOperator(), which the SQL
translation, the HQL rendering and the tree printer all use.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An empty conjunction is true and an empty disjunction is false. An
empty junction used as an operand of another predicate was rendered as
nothing, giving invalid SQL or the wrong truth value.

Render an empty junction as a constant predicate in HQL too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a selection

A criteria query with distinct(true) and no explicit selection must
render distinct in SQL, so that a row limit applies to distinct roots,
and in the HQL rendered for it.

The count and exists queries wrap a distinct or grouped query in a
subquery, which needs a select list. Select the root explicitly when
the criteria query has no explicit selection, and reject the query as
ordinary execution does when it has more than one root.

The single root which such a query selects is now given by
SqmQuerySpec.getImplicitSelection().

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A join of a correlated table group is added to the subquery as a root,
and its predicate is consumed at that point. A restriction given with
on() was applied to the join afterwards and never rendered. Add it to
the restrictions of the subquery instead, for attribute, entity,
derived, function and CTE joins.

Apply the auxiliary restriction of an entity join, such as the one for
soft delete, before the join is registered, so that it is kept too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ction

A join of a collection with soft-deleted elements was always rendered
as a left join, so that an inner join returned owners with no matching
element, and such a join of a correlated root failed an assertion.
An inner join which is not a fetch now keeps its join type.

Every other join is still rendered as a left join. A fetch must not
lose the owner when every element is soft-deleted. A right or full
join would bring back the elements which the join predicate hides.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d maps correctly

Copying JSON_TABLE lost its optional row path, and copying XMLTABLE
shared the column list of the original, added to it while iterating it,
and overwrote the document argument with the columns. Recreate each
function through its descriptor, which supplies the same
dialect-specific SQL conversion as the original, before copying the
columns and the passing expressions.

The PASSING clause of a JSON path expression is now a node of its own,
which is copied, compared and rendered in one place. Render the PASSING
and ON ERROR clauses of JSON_TABLE, with the PASSING names quoted as
identifiers.

In the structural comparison of two maps of SQM nodes, as used for the
query plan cache, a key missing from the other map was treated as
compatible, and the hash only took the last entry into account.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the same thing

The HQL string rendered for an SQM tree must be accepted by the HQL
translator, and must mean the same thing as the tree.

Render state which changes the meaning of a query and was missing:
case-insensitive LIKE and ordering, aggregate and window function
arguments, grouping of arithmetic and duration expressions, element and
index aggregates, fetch and lateral joins, ON predicates of correlated
and treated joins, and OFFSET and FETCH without ORDER BY. Render each
attribute join relative to its owner. Separate a distinct argument from
the next argument, and render the select item itself for a
case-insensitive order by position. Compare the ignoreCase flag in the
structural comparison of sort specifications.

HHH-21174, HHH-21176: A correlation only refers to the outer query, so
it is not rendered as an element of the from clause, and the from
keyword is left out when nothing is rendered. Each join of a correlated
root or of a correlated join is rendered as a root of the subquery with
its restriction in the where clause, including entity, derived table,
function and CTE joins, which threw an assertion failure. Outer joins
keep their restriction in ON, and a lateral join is given a single-row
left side, since HQL has no lateral root. Outer joins of a correlated
join are converted to SQL using the correlated join itself.

HHH-21177: The rendering of a CTE had a list of column names, which HQL
does not allow, declared a CTE with a generated name under a different
name than the from clause used, rendered the name of the materialization
constant, and was not separated from the query which follows it. Give
each CTE a name which is legal and unambiguous in HQL, also when it
collides with an entity name or another CTE, and render the CTEs of an
insert-select after the target fields.

In HQL, keep a root before a correlation which one of its joins
introduces in the from clause.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…agination

HHH-21155: Use the SQM tree itself as the key of the plan of a keyed
query, so that bound parameters stay distinct from inline literals when
plans are reused.

HHH-21161: A case-insensitive key was ordered by its lowercase value but
compared as is when looking for the next page, so rows were skipped or
repeated. The key value is bound as a parameter with the type of the
key, so that an attribute converter is applied to it, also when criteria
values are otherwise inlined as literals.

Use the paths of the sort specifications for the key projection and the
page restriction, so that a key may be a dotted path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hain

In a subquery, a join of a path from the outer query may follow a local
root, and other joins may follow a root which is itself such a path.

Resolve the association against its outer path and record the subquery
root which declares the join. Use the declared order when rendering HQL,
converting to SQL, walking parameters, and copying the SQM tree, so that
a later join may refer to the alias in its ON clause and the generated
SQL has that alias in scope. A later right or full join to a local
entity can preserve unmatched rows, so the correlation predicate stays
in ON in that case.

Attach an entity, cross, derived table or function join which follows a
correlated path root to that path, and to the later path when two paths
of the same outer alias precede it, instead of to the correlation.

Reject a right or full join directly to an outer path during HQL
compilation: the path would have to be restricted before the join.

Work around the precedence which HSQLDB gives a comma before a right or
full join, and its evaluation of a subquery only once when the only
outer reference is in ON.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
grechkovlad and others added 27 commits November 19, 2026 09:16
Port of `org.hibernate.orm.test.jpa.callbacks.PrePersistIdTest`, one of the simplest tests in the suite.

Signed-off-by: vladislavgrecko <vladislav.grechko@jetbrains.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
`BasicEntity` is a Kotlin port of `org.hibernate.testing.orm.domain.gambit.BasicEntity`. The Java test consumes it to verify the kotlin-jpa plugin (synthesized no-arg constructor, open class) and kotlin-from-java interop.

Signed-off-by: vladislavgrecko <vladislav.grechko@jetbrains.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
It was removed as unused, but HHH-21101 had meanwhile started calling it
from HistoryCollectionMutationPlanContributor, breaking compilation of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gavin King <gavin@hibernate.org>
A class mapped with an explicit entity-name is also registered in
entityPersisterMap under its class name. The entityPersisters and
entityNames arrays were built from the map's values and keys, so the
aliased persister was visited twice by forEachEntityDescriptor, and
the class name was reported as an entity name. As a result, a callback
registered with EntityManagerFactory.addListener() fired twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…integer sort key

Signed-off-by: shinseongsu <tlstjdtn321@naver.com>
A temporal attribute whose offset or zone is stored in a separate
column (TimeZoneStorageType.COLUMN, or AUTO on a database without
native time zone support, or the global default storage COLUMN) is
mapped as a composite, so the metamodel built it as a plain
SingularAttribute. The static metamodel declares it TemporalAttribute,
so the field was left null (HHH005001).

HQL already treats these composites as temporals, so build them as
TemporalAttributeImpl, with an embedded path which is also an
SqmTemporalPath.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An attribute mapped with @CompositeType, or with @Embedded or
@EmbeddedId on a class which is not annotated @embeddable, is a plain
SingularAttribute at runtime, whatever its Java type. The processor
chose TemporalAttribute, ComparableAttribute, etc. from the Java type,
so the static metamodel field could not be populated (HHH005001).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An @id or @EmbeddedId declared by an entity subclass, or by a mapped
superclass which extends an entity class, was silently ignored when it
had the same name as the identifier of the root entity, and otherwise
failed with a ClassCastException. It is now rejected with an
AnnotationException which names the subclass and the attribute.

Remove the redundant @id from test models which redeclared it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An overriding property has a field of its own in the subclass, but the
field is not annotated @id unless the annotation is repeated, so such a
subclass is still accepted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* HHH-20592 embeddable patterns in HQL

Allow an embeddable-valued path to be destructured to a tuple by
listing attribute names, so that address(street, zip) is treated
as (address.street, address.zip). This makes comparison with a
tuple independent of the order of the fields of the embeddable.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* HHH-20592 ambiguous attributes and single-attribute embeddable patterns

An ambiguous unqualified attribute which is not of embeddable type
no longer gets in the way of an unregistered function with the same
name. And a pattern with just one attribute is now a path instead
of a tuple with one element, just as (x) is not a tuple.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Group each filter condition before combining it with query or join
restrictions. Cover parameterized and parameter-free OR conditions,
multiple enabled filters, and collection owner isolation.
…apping XSD

so that a transformed hbm.xml property is valid when serialized

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rmed hbm.xml

For a <many-to-one/>, HbmXmlTransformer copies the columns from the boot
model, but carried over only the name, length, precision and scale of
each column, so the unique constraint and the declared SQL type were
missing from the transformed mapping.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ary key

and carry over its on-delete action

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ne-to-one

A <one-to-one/> with a property-ref which is not an association back to
its owner joins the primary key of its owner to a unique key of the
target. It is transformed to a many-to-one with read-only join columns
on the primary key columns, which is not found when unconstrained,
instead of to a primary key join which ignores the property-ref. The
mapping XSD now allows <join-column/> with <property-ref/> in a
<many-to-one/>, as it does in a <one-to-one/>.

The foreign key of a primary key join is written as
<primary-key-foreign-key/>, and <on-delete/> only with a primary key
join, so that the transformed mapping is valid against the XSD.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The Jakarta Data TCK moved countByIdIn() and existsByIdIn() from
CustomRepository to NaturalNumbers. NaturalNumbers$ had no @query
for them, so _NaturalNumbers was not generated and the TCK runner
no longer compiled. CustomRepository$ is left with nothing to
override and is removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e EPOCH

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tomtourwe
tomtourwe force-pushed the codelaser/fix-dead-code-20261120-125740 branch from c290478 to d2fc5af Compare November 20, 2026 16:25
Removes these unused code roots and the code only they use:
- org.hibernate.action.queue.internal.FlushCoordinator.CompositeOperationGroupKey
- org.hibernate.boot.jaxb.hbm.transform.TargetColumnAdapter.setInsertable(java.lang.Boolean)
- org.hibernate.boot.jaxb.hbm.transform.TargetColumnAdapter.setUpdatable(java.lang.Boolean)
- org.hibernate.cache.internal.EnabledCaching.qualifiedRegionName(org.hibernate.cache.spi.DomainDataRegion)
- org.hibernate.collection.spi.PersistentBag.SimpleRemove
- org.hibernate.collection.spi.PersistentList.Add
- org.hibernate.community.dialect.DB2LegacyDialect:FOR_SHARE_SKIP_LOCKED_SQL
- org.hibernate.community.dialect.DB2LegacyDialect:FOR_UPDATE_SKIP_LOCKED_SQL
- org.hibernate.community.dialect.GaussDBDialect.NativeParameterMarkers
- org.hibernate.community.dialect.MySQLLegacyDialect.supportsAliasLocks()
- org.hibernate.community.dialect.MySQLLegacyDialect.supportsForShare()
- org.hibernate.dialect.DB2Dialect:FOR_SHARE_SKIP_LOCKED_SQL
- org.hibernate.dialect.DB2Dialect:FOR_UPDATE_SKIP_LOCKED_SQL
- org.hibernate.dialect.DB2iDialect:FOR_UPDATE_SKIP_LOCKED_SQL
- org.hibernate.dialect.aggregate.internal.SybaseASEAggregateSupport.XmlWriteExpression.isAggregate()
- org.hibernate.orm.post.ClassificationGraph.Edge.getSourceElementId()
- org.hibernate.orm.post.ClassificationReportRenderer.ProjectionEntry.getElementId()
- org.hibernate.processor.validation.MockCollectionPersister.getElementPropertyType(java.lang.String)
- org.hibernate.processor.validation.MockEntityPersister.isSamePersister(org.hibernate.processor.validation.MockEntityPersister)
- org.hibernate.processor.validation.MockSessionFactory.isConstructorDefined(java.lang.String,java.util.List)
- org.hibernate.spatial.predicate.JTSFilterPredicate
- org.hibernate.sql.results.internal.StandardRowReader.ComponentType.getComponentType()
- org.hibernate.tool.hbm2ddl.Exporter
@tomtourwe
tomtourwe force-pushed the codelaser/fix-dead-code-20261120-125740 branch from d2fc5af to 74cfe14 Compare November 21, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.